package cn.imvc.app.repositories;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.imvc.app.entities.Goods;
import cn.imvc.app.entities.GoodsSpec;
import cn.imvc.app.entities.SpecClass;
import cn.imvc.data.jpa.repository.IJpqlExecutor;

public interface GoodsSpecRepository extends JpaRepository<GoodsSpec, Integer>,IJpqlExecutor<GoodsSpec>{
	@Query("select g from GoodsSpec g where g.goods = :goods order by g.specClass.sort asc")
	public List<GoodsSpec> findByGoods(@Param("goods")Goods goods);
	
	@Query("select g from GoodsSpec g where g.goods = :goods and g.specClass = :specClass order by g.specClass.sort asc")
	public List<GoodsSpec> findByGoodsAndSpecClass(@Param("goods")Goods goods,@Param("specClass")SpecClass specClass);
}
